/*<summary>
Created By : Preeti
Created On : 9/20/2008
Class Name : Employee_LoadMapper
Used In    : 
------------------------------------------------------------------------
Modification Log  
------------------------------------------------------------------------
Created By        Modified By         Remarks                             
-----------       ------------        ----------------------------------
                                                                          
------------------------------------------------------------------------
</summary>*/


using System.Xml;
using System.Data;
using System;
using Utils;
using System.Data.SqlClient;

namespace RegistrationController
{
    public class EmployeeInfo_DataLoader
    {
        public EmployeeInfo Get_Employee_DATA(string ID)
        {
            EmployeeInfo objEmployee = new EmployeeInfo();
            ezUtilsAdapter DBL = new ezUtilsAdapter();
            DataChecker dtc = new DataChecker();
            DataSet ds = new DataSet();


            try
            {
                ds = DBL.RunSPReturnDataSet("SP_GetEmployee", "TR", new SqlParameter("@vchID", ID));
                if (ds.Tables[0].Rows.Count > 0)
                {
                    DataRow dr = ds.Tables[0].Rows[0];
                    objEmployee.EmployeeId = Convert.ToString(dr["EmployeeId"]);
                    objEmployee.EmployeeType = Convert.ToString(dr["EmployeeType"]);
                    objEmployee.FName = Convert.ToString(dr["FName"]);
                    objEmployee.LName = Convert.ToString(dr["LName"]);
                    objEmployee.MobilePhone = Convert.ToString(dr["MobilePhone"]);
                    objEmployee.HomePhone = Convert.ToString(dr["HomePhone"]);
                    objEmployee.OfficePhone = Convert.ToString(dr["OfficePhone"]);
                    objEmployee.Email = Convert.ToString(dr["Email"]);
                    objEmployee.Address1 = Convert.ToString(dr["Address1"]);
                    objEmployee.Address2 = Convert.ToString(dr["Address2"]);
                    objEmployee.City = Convert.ToString(dr["City"]);
                    objEmployee.State = Convert.ToString(dr["State"]);
                    objEmployee.ZipCode = Convert.ToString(dr["ZipCode"]);
                    return objEmployee;
                }
                else
                {
                    return objEmployee;
                }
            }
            catch (SqlException ex)
            {
                string errorMessage = String.Format(
                    "An Error Occurred While Loading the Employee Information to the DB. Message: {0}", ex.Message);
                return objEmployee;
            }
            finally
            {
                DBL.Dispose();
                dtc.Dispose();
                ds.Dispose();

            }
        }

        public void Dispose()
        {
            this.Dispose(true);
            System.GC.SuppressFinalize(this);
        }

        private void Dispose(bool disposing)
        {
        }


    }
}